package com.iris.live.services.services;

import com.iris.live.services.data.models.销售项目设置Model;
import com.iris.live.services.models.PageData;
import com.iris.live.services.models.RequestBase;
import com.iris.live.services.models.ResultData;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * Created by lusong on 2016/11/7.
 */
public interface CRMService {

    /**
     * 通过 stage 阶段 获取当前使用的题库及答案
     * @param stage
     * @param permit
     * @return
     */
    public ResultData topicCurrentQuery(String permit, String stage);

    /**
     *  导入题库及答案
     * @param permit
     * @param stage
     * @param username
     * @param list
     * @return
     */
    public ResultData topicLeadingIn(String permit, String username, String stage, List<GetCurrentTopic> list) throws Exception;



    /**
     * 查询sc战败，但CRM战败确认待分配的顾客信息，查询列表
     * @param permit
     * @param pageSize
     * @param pageIndex
     * @param search
     * @return
     */
    public PageData scFailNewAssigned(String permit, int pageIndex, int pageSize, String search);

    /**
     * 查询出 所有的 线索上线未达到上线的 sc信息
     * @param permit
     * @param currentSC
     * @return
     */
    public List<?> getAssignedSC(String permit, String currentSC);

    /**
     * CRM战败确认为1（待分配）的 顾客 分配销售顾问
     * @param permit
     * @param custid
     * @param sccode
     * @return
     */
    public Map updateCusAboutSC(String permit, String username, String custid, String sccode);

//    /**
//     * CRM确认战败或激活
//     * @param permit
//     * @param username
//     * @param getClueOperation
//     * @return
//     */
//    public ResultData updateCRMConfirmFailOrActivation(String permit, String username, GetClueOperation getClueOperation);

    public boolean saveClueAndResign(SaveClueAndResignReq req, String license, String user);

    /**
     * 首次离店、战败、休眠、nps新车交付、crm为当前用户的调研回访记录  调研列表查询
     * @param getCrmSurveyQuery
     * @param permit
     * @return
     */
    public ResultData crmSurveyQuery(CRMService.GetCrmSurveyQuery getCrmSurveyQuery, String permit, String username);

    /**
     * 查询关于集团的crm调研的项目设置
     *
     * @param stage
     * @return
     */
    public ResultData findInstallIntervalDayAndAboutSurvey(String permit, String stage);

    /**
     * 设置首进店离店间隔天数、更换销售顾问后首次接待是否进行调研、新车交车后推送间隔天数
     * @param day
     * @return
     */
    public ResultData installIntervalDayAndAboutSurvey(String permit, String username, String stage, String day);

    public int saveDealerNPSDayNum(String username, List<销售项目设置Model> list);

    public List findDealerNPSDayNum(销售项目设置Model model);

    /**
     * 插入或者修改调研介绍
     * @param permit
     * @param username
     * @param stage
     * @param intent
     * @param target
     * @return
     */
    public ResultData insertOrUpdateSurvey(String permit, String username, String stage, String intent, String target);

    /**
     * 查询调研介绍
     * @param permit
     * @param stage
     * @return
     */
    public ResultData surveyQuery(String permit, String stage);

    /**
     * 查询用于调研的题库
     *
     * @param permit
     * @param stage
     * @return
     */
    public ResultData queryTopicForSurvey(String permit, String username, String stage, String custId, String connectDate, String serialNumber, String id);

    /**
     * 保存题库调研结果
     * @param list
     * @param username
     * @return
     */
    public ResultData topicSurveyResult(List<GetTopicSurveyResult> list, String id, String username) throws Exception;

    /**
     * 查询调研的顾客的背景资料
     *
     * @param stage
     * @param custId
     * @return
     */
    public ResultData cusInfoWhenCrmSurvey(String permit, String username, String stage, String custId, String connectDate, String serialNumber, String id);

    /**
     * 查询某条调研记录
     * @param permit
     * @param username
     * @param stage
     * @param custId
     * @param connectDate
     * @return
     */
    public ResultData querySurveyInfo(String permit, String username, String stage, String custId, String connectDate,
                                      String serialNumber, String id) throws Exception;

//    /**
//     * 查询调研的顾客的调研历史记录
//     *
//     * @param permit
//     * @param stage
//     * @param custId
//     * @return
//     */
//    public ResultData querySurveyHistory(String permit, String username, String stage, String custId);

    /**
     * 保存调研记录，同时给已保存的题库调研结果添加history_id
     *
     * @param getSaveSurveyResult
     * @param permit
     * @param username
     * @return
     */
    public ResultData saveSurveyResult(GetSaveSurveyResult getSaveSurveyResult, String permit, String username) throws Exception;

    /**
     * 查询当日及以前有预约但是问卷状态=待甄别or待预约的调研信息
     *
     * @param permit
     * @param username
     * @return
     */
    public ResultData findNowAndOtherAboutSurvey(String permit, String username, RequestBase requestBase);

    /**
     * 查询预约时间在当前时间和及10分钟内的调研信息
     *
     * @param permit
     * @param username
     * @param requestBase
     * @return
     */
    public ResultData findNowAboutSurveyInTenMinutes(String permit, String username, RequestBase requestBase);

    /**
     * 经销商查询题库导入日志
     *
     * @param permit
     * @return
     */
    public ResultData findTopicLogAboutDealerByPermit(String permit);

    /**
     * 集团查询题库导入日志
     *
     * @param permit
     * @return
     */
    public ResultData findTopicLogAboutGroupByPermit(String permit, String count, String startDate, String endDate);

    public ResultData saveComplaint(SaveComplaintReq req, String license, String loginUser);

    public ResultData getComplaintsList(String license, RequestBase base);

    public ResultData updateComplaintById(UpdateComplaintByIdReq req, String license, String loginUser);

    /**
     * 根据许可查询所有题库版本号
     *
     * @param permit
     * @return
     */
    public ResultData findVersion(String permit);

    /**
     * 导出经销商调研记录
     *
     * @param permit
     * @param version
     * @param connectDateStart
     * @param connectDateEnd
     * @param response
     */
    public void exportDealerSurveyResult(String permit, String version, String connectDateStart, String connectDateEnd, HttpServletResponse response);

    /**
     * 导出集团调研记录
     *
     * @param permit
     * @param version
     * @param connectDateStart
     * @param connectDateEnd
     * @param response
     */
    public void exportGroupSurveyResult(String permit, String version, String connectDateStart, String connectDateEnd, HttpServletResponse response);

    public ResultData getComplaints(GetComplaintsReq req);

    public ResultData findLiVEClue(String permit, GetLiVEClue getLiVEClue);

    public ResultData queryVisitNum(String permit, String username, String stage);

    void exportLiveClueSource(String permit, String createDateStart, String createDateEnd, String lastFollowDateStart,
                              String lastFollowDateEnd, String state, String intentCarLevel, String intentCarStyle,
                              int pageSize, int pageIndex, HttpServletResponse response);

    ResultData queryRateAboutSurveyTopic(String permit, GetQueryRateAboutSurveyTopic getQueryRateAboutSurveyTopic);

    ResultData queryVersionAboutSurveyTopicForGroup(String permit, GetQueryRateAboutSurveyTopic getQueryRateAboutSurveyTopic);

    ResultData queryVersionAboutSurveyTopicForDealer(String permit, GetQueryRateAboutSurveyTopic getQueryRateAboutSurveyTopic);

    void exportCRMSurvey(String permit, String username, CRMService.GetCrmSurveyQuery getCrmSurveyQuery, HttpServletRequest request, HttpServletResponse response);

    ResultData getSurveyResultByStage(String stage);

    List getSurveyLogByHistoryId(String historyId);

    ResultData crmRedistribution(String permit, String username, GetSurveyResultInfo getSurveyResultInfo) throws Exception;

    ResultData crmActivationAndDistribution (String permit, String username, GetSurveyResultInfo getSurveyResultInfo)  throws Exception;

    ResultData crmFollowUp (String permit, String username, GetSurveyResultInfo getSurveyResultInfo) throws Exception;

    ResultData crmExportVoidQuestion (String stage, String permit, String username) throws Exception;

    static class GetSCFailNewAssigned extends RequestBase {
        public String search;
    }

    /**
     * 查询题库返回结果集
     */
    static class GetCurrentTopic {
        public String id;
        public String stage;
        public String type;
        public String number;
        public String lead;
        public String stem;
        public String forward;
        public String version;
        public String remark;

        //新版本添加
        public String select1;
        public String forwardEnding1;
        public String select2;
        public String forwardEnding2;
        public String select3;
        public String forwardEnding3;
        public String select4;
        public String forwardEnding4;
        public String select5;
        public String forwardEnding5;
        public String select6;
        public String forwardEnding6;
        public String select7;
        public String forwardEnding7;
        public String select8;
        public String forwardEnding8;
        public String select9;
        public String forwardEnding9;
        public String select10;
        public String forwardEnding10;
    }

    static class SaveClueAndResignReq{
        public String oldSc;//原销售顾问（email）
        public String newSc;//新销售顾问（email）
        public String oldCusId;//原客户（顾客编号）
        public String newCus; //新客户（姓名）
        public String remark; //备注
        public String newCusPhone; //新顾客电话
        public String isClue;//是否推荐，0否，1是

        public String id;

    }

    /**
     * crm调研查询参数
     */
    static class GetCrmSurveyQuery extends RequestBase {
        public String stage;
        public String cusName;              //顾客姓名
        public String cusPhone;             //顾客电话
        public String researchState;        //调研状态
        public String connectStartDate;       //调研开始日期
        public String connectEndDate;         //调研结束日期
        public String nowState;             //当前处理状态
        public String intentCarVehicles;    //车系
        public String intentCarStyle;       //车款
        public String nextConnectStartDate;   //下次回访开始日期
        public String nextConnectEndDate;     //下次回访结束日期

        public String surveyResult;         //1.8版本新加字段
    }

    /**
     * 调研介绍
     */
    static class GetInsertOrUpdateSurvey{
        public String stage;    //调研阶段
        public String intent;   //调研目的
        public String target;   //调研对象
    }

    /**
     * crm战败确认或激活
     */
    static class GetClueOperation {
        public String historyId;            //调研编号
        public String crmFailConfirm;   //crm战败确认状态
        public String msgContent;       //消息内容
    }

    /**
     *
     */
    static class GetTopicSurveyResult{
        public String topicId;      //题目编号
        public String answerId;     //答案编号
        public String remark;       //备注
        public String openAnswer;   //开放题答案
    }

    static class GetSaveSurveyResult {
        public String id;
        public String stage;
        public String custId;
        public String researchState;
        public String vaild;
        public String nowState;
        public String remark;
        public String otherRemark;
        public String nextConnectDate;

        public String surveyResult;
    }

    static class SaveComplaintReq {
        public String id;
        public String source;//投诉来源
        public String custId;//投诉的顾客编号
        public String target;//投诉对象
        public String content;//投诉内容
    }

    static class UpdateComplaintByIdReq {
        public String id;//投诉表的id
        public String result;//投诉的处理结果
    }

    static class GetFindTopicLogAboutGroupByPermit {
        public String count;
        public String startDate;
        public String endDate;
    }

    static class GetExportSurveyResultData {
        public String area;
        public String version;
        public String connectDateStart;
        public String connectDateEnd;
    }

    static class GetComplaintsReq {
        public String permit;
        public String custId;
    }

    static class GetLiVEClue extends RequestBase {
        public String createDateStart;
        public String createDateEnd;
        public String lastFollowDateStart;
        public String lastFollowDateEnd;
        public String state;
        public String intentCarLevel;
        public String intentCarStyle;
    }

    static class GetQueryRateAboutSurveyTopic {
        public String stage;
        public String startDate;
        public String endDate;
        public String groupVersion;
        public String dealerVersion;
    }

    static class GetSurveyResultInfo {
        public String id;
        public String surveyResult;
        public String nextConnectDate;
        public String reason;
        public String message;
        public String resultType;
    }

    class CurrentSCRequest {
        public String currentSC;
    }

}
